package com.ruoyi.insurance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.insurance.domain.DuringInsuranceEvaluate;
import com.ruoyi.insurance.service.IDuringInsuranceEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 保中安全评测Controller
 * 
 * @author ruoyi
 * @date 2024-09-10
 */
@RestController
@RequestMapping("/insurance/evaluate_before")
public class DuringInsuranceEvaluateController extends BaseController
{
    @Autowired
    private IDuringInsuranceEvaluateService duringInsuranceEvaluateService;

    /**
     * 查询保中安全评测列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:list')")
    @GetMapping("/list")
    public TableDataInfo list(DuringInsuranceEvaluate duringInsuranceEvaluate)
    {
        startPage();
        List<DuringInsuranceEvaluate> list = duringInsuranceEvaluateService.selectDuringInsuranceEvaluateList(duringInsuranceEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出保中安全评测列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:export')")
    @Log(title = "保中安全评测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DuringInsuranceEvaluate duringInsuranceEvaluate)
    {
        List<DuringInsuranceEvaluate> list = duringInsuranceEvaluateService.selectDuringInsuranceEvaluateList(duringInsuranceEvaluate);
        ExcelUtil<DuringInsuranceEvaluate> util = new ExcelUtil<DuringInsuranceEvaluate>(DuringInsuranceEvaluate.class);
        util.exportExcel(response, list, "保中安全评测数据");
    }

    /**
     * 获取保中安全评测详细信息
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") Long evaluateId)
    {
        return success(duringInsuranceEvaluateService.selectDuringInsuranceEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增保中安全评测
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:add')")
    @Log(title = "保中安全评测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DuringInsuranceEvaluate duringInsuranceEvaluate)
    {
        return toAjax(duringInsuranceEvaluateService.insertDuringInsuranceEvaluate(duringInsuranceEvaluate));
    }

    /**
     * 修改保中安全评测
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:edit')")
    @Log(title = "保中安全评测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DuringInsuranceEvaluate duringInsuranceEvaluate)
    {
        return toAjax(duringInsuranceEvaluateService.updateDuringInsuranceEvaluate(duringInsuranceEvaluate));
    }

    /**
     * 删除保中安全评测
     */
    @PreAuthorize("@ss.hasPermi('insurance:evaluate_before:remove')")
    @Log(title = "保中安全评测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateIds)
    {
        return toAjax(duringInsuranceEvaluateService.deleteDuringInsuranceEvaluateByEvaluateIds(evaluateIds));
    }
}
